package com.example.service.impl;

import com.example.common.PageResult;
import com.example.dto.WaterDianPageDto;
import com.example.entity.WaterDian;
import com.example.mapper.WaterDianMapper;
import com.example.service.WaterDianService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WaterDianImpl implements WaterDianService {
    @Autowired
    private WaterDianMapper waterDianMapper;

    @Override
    public PageResult page(WaterDianPageDto waterDianPageDto) {
        PageHelper.startPage(waterDianPageDto.getPageNum(),waterDianPageDto.getPageSize());
        Page<WaterDian> page = waterDianMapper.getByDno(waterDianPageDto);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void add(WaterDian waterDian) {
        waterDianMapper.add(waterDian);
    }

    @Override
    public void deleteByDno(String dno) {
        waterDianMapper.deleteByDno(dno);
    }

    @Override
    public void update(WaterDian waterDian) {
        waterDianMapper.update(waterDian);
    }
}
